package cn.panda.edu.service.impl;


import cn.panda.edu.dao.CourseMapper;
import cn.panda.edu.model.Course;
import cn.panda.edu.service.CourseService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class CourseServiceImpl implements CourseService {

	@Resource
	private CourseMapper courseMapper;

	@Override
	public PageInfo<Course> selectLikeByPrimaryKey( String courseName, Integer pageIndex,
			Integer pageSize) {
		Map<String, Object> map=new HashMap<>();
		//map.put("courseId", courseId);
		map.put("courseName", courseName);
		Page<Course> cList=PageHelper.startPage(pageIndex, pageSize);
		courseMapper.selectLikeByPrimaryKey(map);
		PageInfo<Course> pageInfo=new PageInfo<>(cList);
		return pageInfo;
	}
	@Override
	public PageInfo<Course> selectLikeByPrimaryKey(Integer courseId, String courseName, Integer pageIndex,
			Integer pageSize) {
		Map<String, Object> map=new HashMap<>();
		map.put("courseId", courseId);
		map.put("courseName", courseName);
		Page<Course> cList=PageHelper.startPage(pageIndex, pageSize);
		courseMapper.selectLikeByPrimaryKey(map);
		PageInfo<Course> pageInfo=new PageInfo<>(cList);
		return pageInfo;
	}
	@Override
	public PageInfo<Course> selectCourseByPage(Integer id,Integer pageIndex, Integer pageSize) {
		Page<Course> courses=PageHelper.startPage(pageIndex, pageSize);
		courseMapper.listCourse(id);
		PageInfo<Course> pageInfo=new PageInfo<>(courses);
		return pageInfo;

	}
	@Override
	public int deleteByPrimaryKey(Integer courseId) {
		// TODO Auto-generated method stub
		return courseMapper.deleteByPrimaryKey(courseId);
	}

	@Override
	public int updateByPrimaryKeySelective(Course record) {
		// TODO Auto-generated method stub
		return courseMapper.updateByPrimaryKey(record);
	}

	@Override
	public int insertSelective(Course record) {
		// TODO Auto-generated method stub
		return courseMapper.insertSelective(record);
	}

	@Override
	public Course selectByPrimaryKey(Integer courseId) {
		// TODO Auto-generated method stub
		return courseMapper.selectByPrimaryKey(courseId);
	}
	

}
